72. Araxis Merge File Comparison Report

Produced by Araxis Merge on 2020-08-14 00:01:31 +0000. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

72.1 Files compared

#LocationFileLast Modified
1Porto v3.2.3/Magento 2.x/Porto Theme/app/code/Mageplaza/LayeredNavigation/Model/Layer/FilterAttribute.php2018-10-10 20:33:20 +0000
2Porto v3.2.4/Magento 2.x/Porto Theme/app/code/Mageplaza/LayeredNavigation/Model/Layer/FilterAttribute.php2020-06-26 11:11:14 +0000

72.2 Comparison summary

DescriptionBetween
Files 1 and 2
Text BlocksLines
Unchanged13354
Changed818
Inserted33
Removed11

72.3 Comparison options

WhitespaceConsecutive whitespace is treated as a single space
Character caseDifferences in character case are significant
Line endingsDifferences in line endings (CR and LF characters) are ignored
CR/LF charactersNot shown in the comparison detail
Active line-pairing rules

72.4 Active regular expressions

No regular expressions were active.

72.5 Comparison detail

1 <?php 1 <?php
2 /** 2 /**
3  * Mageplaza 3  * Mageplaza
4  * 4  *
5  * NOTICE OF LICENSE 5  * NOTICE OF LICENSE
6  * 6  *
7  * This source file is subject to the Mageplaza.com license that is 7  * This source file is subject to the Mageplaza.com license that is
8  * available through the world-wide-web at this URL: 8  * available through the world-wide-web at this URL:
9  * https://www.mageplaza.com/LICENSE.txt 9  * https://www.mageplaza.com/LICENSE.txt
10  * 10  *
11  * DISCLAIMER 11  * DISCLAIMER
12  * 12  *
13  * Do not edit or add to this file if you wish to upgrade this extension to newer 13  * Do not edit or add to this file if you wish to upgrade this extension to newer
14  * version in the future. 14  * version in the future.
15  * 15  *
16  * @category    Mageplaza 16  * @category    Mageplaza
17  * @package     Mageplaza_LayeredNavigation 17  * @package     Mageplaza_LayeredNavigation
18  * @copyright   Copyright (c) Mageplaza (https://www.mageplaza.com/) 18  * @copyright   Copyright (c) Mageplaza (https://www.mageplaza.com/)
19  * @license     https://www.mageplaza.com/LICENSE.txt 19  * @license     https://www.mageplaza.com/LICENSE.txt
20  */ 20  */
21  21 
22 namespace Mageplaza\LayeredNavigation\Model\Layer\Filter; 22 namespace Mageplaza\LayeredNavigation\Model\Layer\Filter;
23  23 
24 use Magento\Catalog\Model\Layer as LayerCatalog; 24 use Magento\Catalog\Model\Layer as LayerCatalog;
25 use Magento\Catalog\Model\Layer\Filter\Item\DataBuilder; 25 use Magento\Catalog\Model\Layer\Filter\Item\DataBuilder;
26 use Magento\Catalog\Model\Layer\Filter\ItemFactory; 26 use Magento\Catalog\Model\Layer\Filter\ItemFactory;
27 use Magento\CatalogSearch\Model\Layer\Filter\Attribute as AbstractFilter; 27 use Magento\CatalogSearch\Model\Layer\Filter\Attribute as AbstractFilter;
    28 use Magento\Framework\App\RequestInterface;
28 use Magento\Framework\Filter\StripTags; 29 use Magento\Framework\Filter\StripTags;
29 use Magento\Store\Model\StoreManagerInterface; 30 use Magento\Store\Model\StoreManagerInterface;
30 use Mageplaza\LayeredNavigation\Helper\Data as LayerHelper; 31 use Mageplaza\LayeredNavigation\Helper\Data as LayerHelper;
    32 use Mageplaza\LayeredNavigation\Model\ResourceModel\Fulltext\Collection;
31  33 
32 /** 34 /**
33  * Class Attribute 35  * Class Attribute
34  * @package Mageplaza\LayeredNavigation\Model\Layer\Filter 36  * @package Mageplaza\LayeredNavigation\Model\Layer\Filter
35  */ 37  */
36 class Attribute extends AbstractFilter 38 class Attribute extends AbstractFilter
37 { 39 {
38     /** @var \Mageplaza\LayeredNavigation\Helper\Data */ 40     /** @var LayerHelper */
39     protected $_moduleHelper; 41     protected $_moduleHelper;
40  42 
41     /** @var bool Is Filterable Flag */ 43     /** @var bool Is Filterable Flag */
42     protected $_isFilter = true; 44     protected $_isFilter = true;
43  45 
44     /** @var \Magento\Framework\Filter\StripTags */ 46     /** @var 
StripTags */
45     private $tagFilter; 47     private $tagFilter;
46  48 
47     /** 49     /**
48      * Attribute constructor. 50      * Attribute constructor.
    51      *
49      * @param ItemFactory $filterItemFactory 52      * @param ItemFactory $filterItemFactory
50      * @param StoreManagerInterface $storeManager 53      * @param StoreManagerInterface $storeManager
51      * @param LayerCatalog $layer 54      * @param LayerCatalog $layer
52      * @param DataBuilder $itemDataBuilder 55      * @param DataBuilder $itemDataBuilder
53      * @param StripTags $tagFilter 56      * @param StripTags $tagFilter
54      * @param LayerHelper $moduleHelper 57      * @param LayerHelper $moduleHelper
55      * @param array $data 58      * @param array $data
56      */ 59      */
57     public function __construct( 60     public function __construct(
58         ItemFactory $filterItemFactory, 61         ItemFactory $filterItemFactory,
59         StoreManagerInterface $storeManager, 62         StoreManagerInterface $storeManager,
60         LayerCatalog $layer, 63         LayerCatalog $layer,
61         DataBuilder $itemDataBuilder, 64         DataBuilder $itemDataBuilder,
62         StripTags $tagFilter, 65         StripTags $tagFilter,
63         LayerHelper $moduleHelper, 66         LayerHelper $moduleHelper,
64         array $data = [] 67         array $data = []
65     )
 68     ) {
66     {    
67         $this->tagFilter     = $tagFilter; 69         $this->tagFilter     = $tagFilter;
68         $this->_moduleHelper = $moduleHelper; 70         $this->_moduleHelper = $moduleHelper;
69  71 
70         parent::__construct( 72         parent::__construct(
71             $filterItemFactory, 73             $filterItemFactory,
72             $storeManager, 74             $storeManager,
73             $layer, 75             $layer,
74             $itemDataBuilder, 76             $itemDataBuilder,
75             $tagFilter, 77             $tagFilter,
76             $data 78             $data
77         ); 79         );
78     } 80     }
79  81 
80     /** 82     /**
81      * @inheritdoc 83      * @inheritdoc
82      */ 84      */
83     public function apply(\Magento\Framework\App\RequestInterface $request) 85     public function apply(
RequestInterface $request)
84     { 86     {
85         if (!$this->_moduleHelper->isEnabled()) { 87         if (!$this->_moduleHelper->isEnabled()) {
86             return parent::apply($request); 88             return parent::apply($request);
87         } 89         }
88  90 
89         $attributeValue = $request->getParam($this->_requestVar); 91         $attributeValue = $request->getParam($this->_requestVar);
90         if (empty($attributeValue)) { 92         if (empty($attributeValue)) {
91             $this->_isFilter = false; 93             $this->_isFilter = false;
92  94 
93             return $this; 95             return $this;
94         } 96         }
95  97 
96         $attributeValue = explode(',', $attributeValue); 98         $attributeValue = explode(',', $attributeValue);
97  99 
98         $attribute = $this->getAttributeModel(); 100         $attribute = $this->getAttributeModel();
99         /** @var \Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection $productCollection */ 101         /** @var \Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection $productCollection */
100         $productCollection = $this->getLayer() 102         $productCollection = $this->getLayer()
101             ->getProductCollection(); 103             ->getProductCollection();
102         if (count($attributeValue) > 1) { 104         if (count($attributeValue) > 1) {
103             $productCollection->addFieldToFilter($attribute->getAttributeCode(), ['in' => $attributeValue]); 105             $productCollection->addFieldToFilter($attribute->getAttributeCode(), ['in' => $attributeValue]);
104         } else { 106         } else {
105             $productCollection->addFieldToFilter($attribute->getAttributeCode(), $attributeValue[0]); 107             $productCollection->addFieldToFilter($attribute->getAttributeCode(), $attributeValue[0]);
106         } 108         }
107  109 
108         $state = $this->getLayer()->getState(); 110         $state = $this->getLayer()->getState();
109         foreach ($attributeValue as $value) { 111         foreach ($attributeValue as $value) {
110             $label = $this->getOptionText($value); 112             $label = $this->getOptionText($value);
111             $state->addFilter($this->_createItem($label, $value)); 113             $state->addFilter($this->_createItem($label, $value));
112         } 114         }
113  115 
114         return $this; 116         return $this;
115     } 117     }
116  118 
117     /** 119     /**
118      * @inheritdoc 120      * @inheritdoc
119      */ 121      */
120     protected function _getItemsData() 122     protected function _getItemsData()
121     { 123     {
122         if (!$this->_moduleHelper->isEnabled()) { 124         if (!$this->_moduleHelper->isEnabled()) {
123             return parent::_getItemsData(); 125             return parent::_getItemsData();
124         } 126         }
125  127 
126         $attribute = $this->getAttributeModel(); 128         $attribute = $this->getAttributeModel();
127  129 
128         /** @var \Mageplaza\LayeredNavigation\Model\ResourceModel\Fulltext\Collection $productCollection */ 130         /** @var 
Collection $productCollection */
129         $productCollection = $this->getLayer()->getProductCollection(); 131         $productCollection = $this->getLayer()->getProductCollection();
130  132 
131         if ($this->_isFilter) { 133         if ($this->_isFilter) {
132             $productCollection = $productCollection->getCollectionClone() 134             $productCollection = $productCollection->getCollectionClone()
133                 ->removeAttributeSearch($attribute->getAttributeCode()); 135                 ->removeAttributeSearch($attribute->getAttributeCode());
134         } 136         }
135  137 
136         $optionsFacetedData = $productCollection->getFacetedData($attribute->getAttributeCode()); 138         $optionsFacetedData = $productCollection->getFacetedData($attribute->getAttributeCode());
137  139 
138         if (count($optionsFacetedData) === 0 140         if (count($optionsFacetedData) === 0
139             && $this->getAttributeIsFilterable($attribute) !== static::ATTRIBUTE_OPTIONS_ONLY_WITH_RESULTS 141             && $this->getAttributeIsFilterable($attribute) !== static::ATTRIBUTE_OPTIONS_ONLY_WITH_RESULTS
140         ) { 142         ) {
141             return $this->itemDataBuilder->build(); 143             return $this->itemDataBuilder->build();
142         } 144         }
143  145 
144         $productSize = $productCollection->getSize(); 146         $productSize = $productCollection->getSize();
145     
146         $itemData   = []; 147         $itemData    = [];
147         $checkCount = false; 148         $checkCount  = false;
148  149 
149         $options = $attribute->getFrontend()
 150         $options = $attribute->getFrontend()->getSelectOptions();
150             ->getSelectOptions();    
151         foreach ($options as $option) { 151         foreach ($options as $option) {
152             if (empty($option['value'])) { 152             if (empty($option['value'])) {
153                 continue; 153                 continue;
154             } 154             }
155  155 
156             $value = $option['value']; 156             $value = $option['value'];
157  157 
158             $count = isset($optionsFacetedData[$value]['count']) 158             $count = isset($optionsFacetedData[$value]['count'])
159                 ? (int)
$optionsFacetedData[$value]['count']
 159                 ? (int) $optionsFacetedData[$value]['count']
160                 : 0; 160                 : 0;
161  161 
162             // Check filter type 162             // Check filter type
163             if ($this->getAttributeIsFilterable($attribute) ==
 static::ATTRIBUTE_OPTIONS_ONLY_WITH_RESULTS
 163             if ($this->getAttributeIsFilterable($attribute) === static::ATTRIBUTE_OPTIONS_ONLY_WITH_RESULTS
164                 && (!$this->_moduleHelper->getFilterModel()->isOptionReducesResults($this, $count, $productSize)) 164                 && (!$this->_moduleHelper->getFilterModel()->isOptionReducesResults($this, $count, $productSize))
165             ) { 165             ) {
166                 continue; 166                 continue;
167             } 167             }
168  168 
169             if ($count > 0) { 169             if ($count > 0) {
170                 $checkCount = true; 170                 $checkCount = true;
171             } 171             }
172  172 
173             $itemData[] = [ 173             $itemData[] = [
174                 'label' => $this->tagFilter->filter($option['label']), 174                 'label' => $this->tagFilter->filter($option['label']),
175                 'value' => $value, 175                 'value' => $value,
176                 'count' => $count 176                 'count' => $count
177             ]; 177             ];
178         } 178         }
179  179 
180         if ($checkCount) { 180         if ($checkCount) {
181             foreach ($itemData as $item) { 181             foreach ($itemData as $item) {
182                 $this->itemDataBuilder->addItemData($item['label'], $item['value'], $item['count']); 182                 $this->itemDataBuilder->addItemData($item['label'], $item['value'], $item['count']);
183             } 183             }
184         } 184         }
185  185 
186         return $this->itemDataBuilder->build(); 186         return $this->itemDataBuilder->build();
187     } 187     }
188 } 188 }